package com.ssm.service.impl;

import com.ssm.dao.StudentMapper;
import com.ssm.dao.UmStudentMapper;
import com.ssm.entity.Student;
import com.ssm.entity.UmStudent;
import com.ssm.entity.UmStudentExample;
import com.ssm.service.StudentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("studentService")
public class StudentServiceImpl implements StudentService {

    @Resource(name = "studentMapper")
    private StudentMapper studentMapper;

    @Resource(name = "umStudentMapper")
    private UmStudentMapper umStudentMapper;

    @Override
    public Student login(int id, String password) {
        return studentMapper.selectByLogin(id,password);
    }

    @Override
    public List<UmStudent> listAllStudent() {
        return umStudentMapper.selectByExample(new UmStudentExample());
    }

    @Override
    public Integer createStudent(UmStudent umStudent) {
        return umStudentMapper.insertSelective(umStudent);
    }

    @Override
    public Integer update(UmStudent umStudent) {
        return umStudentMapper.updateByPrimaryKeySelective(umStudent);
    }

    @Override
    public Integer deleteStudent(int id) {
        return umStudentMapper.deleteByPrimaryKey(id);
    }

    @Override
    public UmStudent getUmStudent(int id) {
        return umStudentMapper.selectByPrimaryKey(id);
    }
}
